package com.zhiyou.controller;

import com.zhiyou.entity.PowerCenter;
import com.zhiyou.util.PWUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

/**
 * @author sanshi
 * @desc
 * @create 2021-09-08 11:12
 */
@WebServlet("/DoSearchServlet")
public class DoSearchServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String searchName = req.getParameter("searchName");
        PWUtil pwUtil = new PWUtil();
        String sql = "select * from sys_user_chnl where acct like ?";
        Object[] params = {"%"+searchName+"%"};
        List<PowerCenter> pcList = pwUtil.searchByCondition3(sql, params);
        HttpSession session = req.getSession();
        session.setAttribute("pcList",pcList);
        resp.sendRedirect("../page/AccountManagement.jsp");
    }
}
